Write a PL/SQL code to find whether a given string is a palindrome or not.
Write a PL/SQL code to find whether a given string is a palindrome or not.
44204-Apr-2023
Updated on 05-Apr-2023
Home / DeveloperSection / Forums / Write a PL/SQL code to find whether a given string is a palindrome or not.
Krishnapriya Rajeev
05-Apr-2023The following PL/SQL program checks whether the given string is a palindrome or not:
We first declare the variables str (the string to be checked), rev (to store the reversed string), and c (to extract each character). Using a FOR loop that iterates from the length of the string to 1, we extract each character from the string and concatenate it to the reversed string. Finally, we check if str and rev are equal. If they are, the string is a palindrome.